package com.future.lock.mall.widgets;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;

import com.future.lock.R;
import com.yzh.modaldialog.dialog.impl.PopupDialog;


public class NoticePopupDialog extends PopupDialog {
    protected TextView mTitleTextView;
    protected TextView contentTextView;
    protected TextView confirmBtn;
    protected TextView cancelBtn;

    protected String title;
    protected String confirm;
    protected CharSequence content;
    private String cancel;

    public NoticePopupDialog(@NonNull Context context) {
        super(context, R.layout.dialog_web_view_notices);
    }

    @Override
    protected void onDialogCreate(Dialog dialog, Bundle savedInstanceState) {
        setGravity(Gravity.CENTER);
        super.onDialogCreate(dialog, savedInstanceState);
        this.mTitleTextView = dialog.findViewById(R.id.titleTextView);
        this.contentTextView = dialog.findViewById(R.id.contentTextView);
        this.confirmBtn = dialog.findViewById(R.id.confirmBtn);
        this.cancelBtn = dialog.findViewById(R.id.cancelBtn);
        this.confirmBtn.setOnClickListener(view -> endModal(AlertDialog.BUTTON_NEGATIVE));
        this.cancelBtn.setOnClickListener(view -> endModal(AlertDialog.BUTTON_NEUTRAL));

        this.mTitleTextView.setText(title);
        this.confirmBtn.setText(confirm);
        this.confirmBtn.setVisibility(!TextUtils.isEmpty(confirm) ? View.VISIBLE : View.GONE);
        this.cancelBtn.setText(cancel);
        this.cancelBtn.setVisibility(!TextUtils.isEmpty(cancel) ? View.VISIBLE : View.GONE);
        this.contentTextView.setText(content);

    }

    public void setTitle(String title) {
        this.title = title;
    }

    public void setConfirm(String confirm) {
        this.confirm = confirm;
    }

    public void setCancel(String cancel) {
        this.cancel = cancel;
    }

    public void setContent(CharSequence content) {
        this.content = content;
    }
}
